<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>四舍五入，输入一个小数如果小数点后大于 3 位那么四舍五
    入保留两位，小于 3 位不变，比如输入 1.655 返回 1.66，
    输入 1.65 返回 1.65。</title>
</head>

<body>
  <script>

    function numRadm(num) {
      var res = num.toString().split('.').pop().length;
      if (res > 3) {
        return num.toFixed(2)
      } else {
        return res
      }
    }
    console.log(numRadm(1.25555335))


    let a = 12.1156
    if (a.toFixed(3).length >= 3) {
      console.log(a.toFixed(2))
    } else {
      console.log(a.toFixed(2))
    }
  </script>
</body>

</html>